<template>
	<view style="margin-left:10rpx;margin-right: 10rpx;background-color: #F7FFFD; height: 100%;">
		<view v-for="(item , index) in data.pages" :key="index">
			<!-- 轮播图 -->
			<Banner :image="item.list" v-if="item.type == 'banner'"></Banner>
			<!-- 三公图 -->
			<view v-if="item.type == 'blockMenu3'" class="m-t-b-sm">
				<BlockSan3 :list="item.list"></BlockSan3>
			</view>
			<!-- 店铺信息 -->
			<view v-if="item.type == 'shopInfo'">
				<ShopItem :list="item.list"></ShopItem>
			</view>
			<!-- 卡片信息 -->
			<view v-if="item.type == 'infoCard'">
				<InfoCard></InfoCard>
			</view>
			<view v-if="item.type == 'list'">
				<List></List>
			</view>
			<!-- 头部标题 -->
			<view v-if="item.type == 'titleTop'">
				<TitleTop :info="item"></TitleTop>
			</view>
			<!-- 选项 -->
			<view v-if="item.type == 'tabs'">
				<u-tabs :list="item.list" @click="clickTab"></u-tabs>
			</view>
		</view>

		<u-list @scrolltolower="scrolltolower" :pagingEnabled="true">
			<listItem v-for="(listItem , listIndex) in data.list" :key="listIndex"></listItem>
		</u-list>

	</view>
</template>

<script>
	import Banner from "@/components/banner/banner.vue"
	import BlockSan3 from "@/components/menu/blockScan3.vue"
	import ShopItem from "@/components/layout/shopItem.vue"
	import InfoCard from "@/components/layout/infoCard.vue"
	import TitleTop from "@/components/layout/titleTop.vue"
	import List from "@/components/layout/list.vue"
	import listItem from "@/components/layout/listItem.vue"

	export default {
		components: {
			Banner,
			BlockSan3,
			ShopItem,
			InfoCard,
			List,
			TitleTop,
			listItem,
		},
		data() {
			return {
				firstLoading:false,
				loading: true,
				data: {},
			}
		},
		onLoad(e) {
			console.log(e)
			uni.showLoading()
			let that = this;
			setTimeout(function(){
				 that.initData()
				that.getData()
				uni.hideLoading()
			},1000)
			
			// this.getData()
		},
		methods: {
			clickTab(e) {
				uni.showLoading()
				let that = this
				console.log(e)
				this.data.list = [];
				setTimeout(function() {
					that.getData();
				}, 1000)

			},
			scrolltolower() {
				console.log('触底')
			},
			
		    initData(){
				
				//根据loading的中的参数去获取初始值
				
				
				this.data = {
					url:'/order/list',
					list: [],
					page: 1,
					pages: [
						{
							type: "titleTop",
							title: '我的订单',
							subtitle: ''
						},
						{
							type: "tabs",
							list: [{
									name: '全部'
								},
								{
									name: '未付款'
								},
								{
									name: '已付款'
								},
							],
						},
					],

				}
			},

			getData() {
				uni.hideLoading()
				console.log(this.data.url);
				//给信息
				this.data.list = [{
						title: "hello"
					},
					{
						title: "hello"
					},
					{
						title: "hello"
					},
					{
						title: "hello"
					},
					{
						title: "hello"
					},

				];
			}

		},
	}
</script>

<style>
	page {
		background-color: #F7FFFD
	}
</style>